 var MMTouchLayer = cc.Layer.extend({

 	ctor : function(){

 		this._super();

 		this.playMusic();

 		this.initMenu();

 	},
 	playMusic : function(){
 		if(GC.SOUND_ON){
 			if(cc.audioEngine.isMusicPlaying()){
 				return;
 			}
 			cc.audioEngine.playMusic(res.mm_bgMusic_mp3, true);
 		}
 	},
 	initMenu : function(){
 		/*var flare = new cc.Sprite(res.mm_flare_jpg);

 		flare.visible =  false;

 		this.addChild(flare, 10);*/


 		var newGameNormal = new cc.Sprite(res.mm_mune_png, cc.rect(0, 0, 126, 33));
        var newGameSelected = new cc.Sprite(res.mm_mune_png, cc.rect(0, 33, 126, 33));
        var newGameDisabled = new cc.Sprite(res.mm_mune_png, cc.rect(0, 33 * 2, 126, 33));

        var gameSettingsNormal = new cc.Sprite(res.mm_mune_png, cc.rect(126, 0, 126, 33));
        var gameSettingsSelected = new cc.Sprite(res.mm_mune_png, cc.rect(126, 33, 126, 33));
        var gameSettingsDisabled = new cc.Sprite(res.mm_mune_png, cc.rect(126, 33 * 2, 126, 33));

        var aboutNormal = new cc.Sprite(res.mm_mune_png, cc.rect(252, 0, 126, 33));
        var aboutSelected = new cc.Sprite(res.mm_mune_png, cc.rect(252, 33, 126, 33));
        var aboutDisabled = new cc.Sprite(res.mm_mune_png, cc.rect(252, 33 * 2, 126, 33));

        var newGame = new cc.MenuItemSprite(
        	newGameNormal,
        	newGameSelected,
        	newGameDisabled,
            this.onNewGame,
            this
        	/*function(){
        		this.onButtonEffect();
        		this.flareEffect(flare, this, this.onNewGame);
        	}.bind(this)*/
        );
        var gameSettings = new cc.MenuItemSprite(
        	gameSettingsNormal,
            gameSettingsSelected,
            gameSettingsDisabled,
            this.onSettings,
            this	
        );
        var about = new cc.MenuItemSprite(
        	aboutNormal,
            aboutSelected,
            aboutDisabled,
            this.onAbout,
            this
        );
        var menu = new cc.Menu(newGame, gameSettings, about);
        menu.alignItemsVerticallyWithPadding(10);
        menu.x = GC.w_2;
        menu.y = GC.h_2 - 80;
        this.addChild(menu, 1, 2);
 	},
 	onNewGame : function(){
 		cc.audioEngine.stopMusic();
 		cc.director.runScene(new cc.TransitionFade(1.2, new GamePlayScene()));
 	},
 	onSettings : function(){
 		this.onButtonEffect();
        cc.director.runScene(new cc.TransitionFade(1.2, new SettingScene()));
 	},
 	onAbout : function(){
 		this.onButtonEffect();
        cc.director.runScene(new cc.TransitionFade(1.2, new AboutScene()));
 	},
 	onButtonEffect : function(){
 		if(GC.SOUND_ON){
 			cc.audioEngine.playEffect(res.mm_btneffect);
 		}
 	},
 	flareEffect : function(flare,target, callback){
        flare.stopAllActions();

//        设置flare 的渲染混合模式
        flare.setBlendFunc(cc.SRC_ALPHA, cc.ONE);
        flare.attr({
            x: -30,
            y: 297,
            visible: true,
            opacity: 0,
            rotation: -120,
            scale: 0.2
        });

//   不懂  这些代码 

//        定义动作
        var opacityAnim = cc.fadeIn(0.5, 255);
        var opacDim = cc.fadeIn(1, 0);

//        为动作加上easing效果，具体参考tests里面的示例
        var biggerEase = cc.scaleBy(0.7, 1.2, 1.2).easing(cc.easeSineOut());
        var easeMove = cc.moveBy(0.5, cc.p(328, 0)).easing(cc.easeSineOut());
        var rotateEase = cc.rotateBy(2.5, 90).easing(cc.easeExponentialOut());
        var bigger = cc.scaleTo(0.5, 1);

//        函数回调动作
        var onComplete = cc.callFunc(callback, target);
        var killflare = cc.callFunc(function () {
            this.getParent().removeChild(this,true);
        }, flare);

//        按顺序执行一组动作
        var seqAction = cc.sequence(opacityAnim, biggerEase, opacDim, killflare, onComplete);

//        同时执行一组动作
        var action = cc.spawn(seqAction, easeMove, rotateEase, bigger);
        flare.runAction(action);
    }
 });